package com.hua.fanqiemall.product.service.impl;

import com.hua.fanqiemall.product.vo.SpuSaveReqVo;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hua.common.utils.PageUtils;
import com.hua.common.utils.Query;

import com.hua.fanqiemall.product.dao.SpuInfoDao;
import com.hua.fanqiemall.product.entity.SpuInfoEntity;
import com.hua.fanqiemall.product.service.SpuInfoService;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * spu服务实现类
 *
 * @author luoweihua
 * @email lwh_559@163.com
 * @date 2021-12-09 22:14:00
 */
@Service("spuInfoService")
public class SpuInfoServiceImpl extends ServiceImpl<SpuInfoDao, SpuInfoEntity> implements SpuInfoService {

    /**
     * 原始分页查询接口
     * @param params 查询参数
     * @return PageUtils
     */
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<SpuInfoEntity> page = this.page(
                new Query<SpuInfoEntity>().getPage(params),
                new QueryWrapper<>()
        );

        return new PageUtils(page);
    }

    /**
     * 保存SPU信息接口
     * @author luoweihua
     * @date 2022/1/12 18:23
     * @param reqVo 接口入参
     */
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    @Override
    public void saveSpuInfo(SpuSaveReqVo reqVo) {
        //1、保存spu基本信息 pms_spu_info

        //2、保存spu的描述图片 pms_spu_info_desc

        //3、保存spu的图片集 pms_spu_images

        //4、保存spu的规格参数 pms_product_attr_value

        //5、保存spu积分信息 sms_spu_bounds

        //5、保存当前spu对应的所有sku信息;
        //5.1)、sku的基本信息;pms_sku_info
        //5.2)、sku的图片信息;pms_sku_images
        //5.3)、sku的销售属性信息:pms_sku_sale_attr_value
        //5.4)、sku的优惠、满减等信息;fanqiemall_sms->sms_sku_ladder
        //     sms_sku_full_reduction\sms_member_price

    }

}